package com.jacky.dubbo3;

import com.jacky.dubbo3.proto.Greeter;
import com.jacky.dubbo3.proto.GreeterReply;
import com.jacky.dubbo3.proto.GreeterRequest;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class Task implements CommandLineRunner {

    private static final Logger LOGGER = LoggerFactory.getLogger(Task.class);

    @DubboReference
    private Greeter greeter;

    @Override
    public void run(String... args) throws Exception {
        GreeterReply reply = greeter.greet(GreeterRequest.newBuilder().setName("Joe").build());
        LOGGER.info("consumer received reply:{}", reply.getMessage());
    }
}
